package 周赛;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

public class 环和杆 {
    public int countPoints(String rings) {
        Map<Character, HashSet<Character>> map = new HashMap<>();
        char[] chars = rings.toCharArray();
        for (int i = 1; i < chars.length; i+=2) {
            if (!map.containsKey(chars[i])){
                HashSet<Character> set = new HashSet<>();
                set.add(chars[i-1]);
                map.put(chars[i],set);
            }
            HashSet<Character> characters = map.get(chars[i]);
            characters.add(chars[i-1]);
            map.put(chars[i],characters);
        }
        int num = 0;
        for (Character character : map.keySet()) {
            if (map.get(character).size()==3)
                num++;
        }
        return num;
    }
}
